﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;


namespace _15梁佩雯
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder(1024);
            sb.Append("INSERT INTO Student ");
            sb.Append(" (No, Name, Age, College, Gender, Address, Class) ");
            sb.Append("VALUES   (@No,@Name,@Age,@College,@Gender,@Address,@Class) ");
            SqlParameter[] pms = new SqlParameter[7];
            pms[0] = new SqlParameter("@No", this.No.Text);
            pms[1] = new SqlParameter("@Name", this.Name.Text);
            pms[2] = new SqlParameter("@Age", this.Age.Text);
            pms[3] = new SqlParameter("@College", this.College.Text);
            pms[4] = new SqlParameter("@Address", this.Address.Text);
            pms[5] = new SqlParameter("@Gender", this.Gender.Text);
            pms[6] = new SqlParameter("@Class", this.Class.Text);
            int intResult = SqlHelper.ExecuteNonQuery(sb.ToString(), pms);
            this.lblInfo.Text = (intResult < 1) ? "添加失败！" : "添加" + intResult.ToString() + "条记录！";
        }
    }
}